<?php
/**
 * @title: 登录登出
 * @desc:
 */
namespace app\admin\controller;

use app\common\controller\Base;
use app\common\tools\Crypto;
class Login extends Base {

    /**
     * 用户登录【账号密码登录】
     */
    public function index()
    {
        $username = $this->request->post('username');
        $password = $this->request->post('password');

        //$password = Crypto::userMd5($password); return $password;

        return \app\admin\logic\Login::loginHandle($username,$password,3);
    }


    /**
     * 用户登录【账号密码登录】
     */
    public function logout()
    {
        $ApiAuth = $this->request->header('ApiAuth');
        cache('Login:' . $ApiAuth, null);
        cache('Login:' . $this->userInfo['id'], null);

        return $this->buildSuccess([], '登出成功');
    }
}